﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SolutionModel;
using SolutionBLL;
using SFast;

namespace MvcUI.Areas.AdminWeb.Controllers
{
    public class IndexController : Controller
    {
        //
        // GET: /AdminWeb/Index/

        public ActionResult Index()
        {
            return View();
        }

        public String GetMenuTree()
        {
            T_MenuBLL bll = new T_MenuBLL();
            List<T_Menu> menu = bll.getMenuByUsesrID("8189a7c1-6f15-4744-b6c4-d3ee5b5b994d");
            List<EasyTreeModel> list = new List<EasyTreeModel>();
            menu.ForEach(o =>
            {
                EasyTreeModel model = new EasyTreeModel();
                model.id = o.C_ID;
                model.text = o.C_Name;
                model.pid = (int)o.C_Parent_ID;
                model.url = o.C_Url;
                list.Add(model);
            });

            list.ForEach(o =>
            {
                o.children = list.Where(l => l.pid == o.id).ToList();
            });

            return list.Where(o=> o.pid==0)._ToJsonStr();
        }

    }
}
